package com.chen.auth.domain.service.impl;

import com.chen.auth.common.enums.IsDeletedFlagEnum;
import com.chen.auth.domain.convert.AuthRoleBOConverter;
import com.chen.auth.domain.entity.AuthRoleBO;
import com.chen.auth.domain.service.AuthRoleDomainService;
import com.chen.auth.infra.basic.entity.AuthRole;
import com.chen.auth.infra.basic.mapper.AuthRoleMapper;
import com.chen.auth.infra.basic.service.AuthRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (AuthRole)表服务实现类
 *
 * @author makejava
 * @since 2024-06-20 15:39:24
 */
@Service
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {
    @Resource
    private AuthRoleService authRoleService;


    @Override
    public AuthRole queryById(Long id) {
        return null;
    }
    /**
     * 修改角色信息
     */
    @Override
    public Boolean update(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBOToEntity(authRoleBO);
        return authRoleService.update(authRole)>0;
    }


    /**
     * 添加角色
     */
    @Override
    public Boolean add(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBOToEntity(authRoleBO);
        authRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        Integer count = authRoleService.insert(authRole);
        return count > 0;

    }

    /**
     * 删除角色信息
     */
    @Override
    public Boolean delete(AuthRoleBO authRoleBO) {
        AuthRole authRole = new AuthRole();
        authRole.setId(authRoleBO.getId());
        authRole.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return authRoleService.update(authRole)>0;
    }
}
